****** TABLE A1 ******
clear all
set more off 
capture log close
 
* main  path to data folder
global path "~/Dropbox/Paraguay/1_data/7_replication_dataverse"
capture cd "$path"	

*tables = analysis tables
global tables "$path/tables"

eststo clear


** Centrality data at the family-municipality level

use "$path/data/centrality_family.dta", clear

label variable eigenvector "Eigenvector Centrality"
label variable degree "Degree Centrality"
label variable betweenness "Betweenness Centrality"

eststo clear
* use only observations in main sample
estpost sum eigenvector degree betweenness if sample_weight == 1
est store panel_a

	
esttab panel_a using "$tables/tableA1.tex", replace ///
prehead("\begin{tabular}{lccccc} \hline \hline" ///
       "& Mean & Std.Dev. & Min & Max & Obs \\ \hline") ///
mtitles() ///
collabels(none) ///
refcat(eigenvector "\multicolumn{5}{l}{\textbf{\emph{(a) Family Network Centrality}}}", nolabel) ///
cells("mean(fmt(%9.3fc)) sd(fmt(%9.3fc)) min(fmt(0)) max(fmt(%9.0fc)) count(fmt(%9.0fc))") ///
label nonumber f noobs alignment(S) booktabs


** Centrality data at municipality level


use "$path/data/centrality.dta", clear


label variable lambda "Largest Eigenvalue"
label variable degree_mean "Average Degree"
label variable betweenness_mean "Average Betweenness"

eststo clear
estpost sum lambda degree_mean betweenness_mean
est store panel_a_alt

esttab panel_a_alt  using "$tables/tableA1.tex", append ///
mtitles() ///
collabels(none) ///
cells("mean(fmt(%9.3fc)) sd(fmt(%9.3fc))  min(fmt(0)) max(fmt(%9.0fc)) count(fmt(%9.0fc))") label nonumber f noobs alignment(S) booktabs 



** Land data
  
use "$path/data/main.dta", clear 


label variable tmh_ha_log "Hectares of land (log)"
label variable tmh_e "Land Grant (binary)"
label variable tmh_ha "Hectares of land"
label variable tmh_n "Number of plots"


eststo clear
estpost sum tmh_ha_log  tmh_ha tmh_n tmh_e if sample_weight == 1
est store panel_b

	
esttab panel_b  using "$tables/tableA1.tex", append ///
mtitles() ///
collabels(none) ///
refcat(tmh_ha_log "\multicolumn{5}{l}{\textbf{\emph{(b) Ill-Gotten Public Lands}}}", nolabel) ///
cells("mean(fmt(%9.3fc)) sd(fmt(%9.3fc))  min(fmt(0)) max(fmt(%9.0fc)) count(fmt(%9.0fc))") label nonumber f noobs alignment(S) booktabs 


** Land data with placebo sample

*** keep only departments that are in the placebo sample


drop if departamento == "caaguazu / yhu"
drop if departamento == "caazapa"
drop if departamento == "cordillera / caraguatay"
drop if departamento == "guaira"
drop if departamento == "itapua / encarnacion"
drop if departamento == "misiones / san ignacio"
drop if departamento == "neembucu / pilar"
drop if departamento == "paraguari / quiindy"
drop if departamento == "seccion occidental / chaco"



eststo clear
estpost sum tmh_ha_log  tmh_ha tmh_n tmh_e if sample_weight == 1
est store panel_c

	
esttab panel_c  using "$tables/tableA1.tex", append ///
mtitles() ///
collabels(none) ///
refcat(tmh_ha_log "\multicolumn{5}{l}{\textbf{\emph{(c) Ill-Gotten Public Lands (Concepción and San Pedro)}}}", nolabel) ///
cells("mean(fmt(%9.3fc)) sd(fmt(%9.3fc))  min(fmt(0)) max(fmt(%9.0fc)) count(fmt(%9.0fc))")  label nonumber f noobs alignment(S) booktabs 




** Placebo sample

use "$path/data/indert.dta", clear

			
label variable grants_ha_log "Hectares of land (log)"
label variable grants_e "Land Grant (binary)"
label variable grants_ha "Hectares of land"
label variable grants_n "Number of plots"

		
estpost sum grants_ha_log  grants_ha  grants_n grants_e if sample_weight == 1
est store panel_d

	
esttab panel_d  using  "$tables/tableA1.tex", append ///
mtitles() ///
collabels(none) ///
refcat(grants_ha_log "\multicolumn{5}{l}{\textbf{\emph{(d) Legitimate Public Lands (Concepción and San Pedro)}}}", nolabel) ///
cells("mean(fmt(%9.3fc)) sd(fmt(%9.3fc))  min(fmt(0)) max(fmt(%9.0fc)) count(fmt(%9.0fc))")  label nonumber f noobs alignment(S) booktabs 




** Party membership data
  

use "$path/data/anr.dta", clear

* drop a department that has only one municipality and does not go in the analysis

drop if departamento == "seccion occidental / chaco"

label variable anr_aff "Colorado Party Affiliations"
label variable l_anr "Colorado Party Affiliations (log)"


estpost sum anr_aff l_anr 
est store panel_e

	
esttab panel_e  using "$tables/tableA1.tex", append ///
mtitles() ///
collabels(none) ///
refcat(anr_aff "\multicolumn{5}{l}{\textbf{\emph{(e) Colorado Party Affiliations}}}", nolabel) ///
cells("mean(fmt(%9.3fc)) sd(fmt(%9.3fc))  min(fmt(0)) max(fmt(%9.0fc)) count(fmt(%9.0fc))")  label nonumber f noobs alignment(S) booktabs 


** Rural collective action data


use "$path/data/landinv.dta", clear


label variable l_linv "Episodes of Land Occupations (log)"
label variable linv_b "Proportion Land Occupations"
label variable l_peasfam "Squatter Peasants (log)"
label variable l_hectares "Occupied Hectares (log)"



estpost sum l_linv linv_b l_peasfam l_hectares
est store panel_f

	
esttab panel_f using "$tables/tableA1.tex", append ///
mtitles() ///
collabels(none) ///
refcat(l_linv "\multicolumn{5}{l}{\textbf{\emph{(f) Rural Collective Action}}}", nolabel) ///
cells("mean(fmt(%9.3fc)) sd(fmt(%9.3fc)) min(fmt(0)) max(fmt(%9.0fc)) count(fmt(%9.0fc))") ///
label nonumber f noobs alignment(S) booktabs ///
postfoot("\hline \hline \\" ///
        "\end{tabular}")







